﻿using AutoMapper;
using BusinessLogic.Model;
using DataAccess.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BusinessLogic.AutoMapper
{
    public class ProductMapping
    {
        public static void Configure()
        {
            Mapper.CreateMap<Product, ProductItem>();
            Mapper.CreateMap<Product, ProductItem>().ForMember(
                x => x.Price, map => map.MapFrom(p => p.Price.ToString("0,0")));
            Mapper.CreateMap<Product, ProductItem>().ForMember(
                x => x.SalePrice, map => map.MapFrom(p => (p.Price / 100 * (100 - p.Sale)).ToString("0,0")));
            Mapper.CreateMap<ProductAddNew, Product>();

            Mapper.CreateMap<Product, ProductDetail>();
            Mapper.CreateMap<Product, ProductDetail>().ForMember(
                x => x.BasePrice, map => map.MapFrom(p => p.Price.ToString("0,0")));
            Mapper.CreateMap<Product, ProductDetail>().ForMember(
               x => x.SalePrice, map => map.MapFrom(p => (p.Price / 100 * (100 - p.Sale)).ToString("0,0")));
        }
    }
}
